<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单详情列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label id="orderNoLabel">提货单号：</label>
                            <input type="text" name="orderNo"/>
                        </li>
                        <li hidden="hidden" >
                            <label>产品id：</label>
                            <input type="text" name="productId"/>
                        </li>
                        <li hidden="hidden">
                            <label>供应商ID：</label>
                            <input type="text" name="supplierId"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm hidden" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add2()" shiro:hasPermission="mall:mallOrderDetail:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit2()" shiro:hasPermission="mall:mallOrderDetail:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="mall:mallOrderDetail:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="mall:mallOrderDetail:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('mall:mallOrderDetail:edit')}]];
    var removeFlag = [[${@permission.hasPermi('mall:mallOrderDetail:remove')}]];
    var statusDatas = [[${@dict.getType('b_order_detail_status')}]];

    var contractId=[[${contractId}]];
    var orderId=[[${orderId}]];
    var contractType=[[${contractType}]];

    var  prefix= ctx + "warehouse/orderDetail";

    var url=prefix+"/list?"
    if(contractId !=null && contractId !="null"){
        url=url+"contractId="+contractId;
    }

    if(orderId != null){
        //根据订单id，查询订单订单详情
        url=url+"orderId="+orderId;
    }

    if(isBuyContractType()){
        $("#orderNoLabel").text('提货单号');
    }else{
        $("#orderNoLabel").text('销货单号');
    }
    function isBuyContractType(){
        if(contractTypeObj.buy==contractType){
            return true;
        }
        return  false;
    }
    $(function() {
        var options = {
            url: url,
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            sortName: "orderDetailId",
            sortOrder:"desc",
            modalName: isBuyContractType()?"采购单详情":"销货单详情",
            columns: [{
                checkbox: true
            },
                {
                    field: 'orderDetailId',
                    title: '序号',
                    visible: false,
                },
                {
                    field: 'warehouseId',
                    title: '创库',
                    visible: false,
                    formatter: function(value, row, index) {
                        return 1
                    }
                },
                {
                    field: 'orderNo',
                    title: isBuyContractType()?'提货单号':'销货单号',
                },
                {
                    field: 'name',
                    title: '产品名称'
                },
                {
                    field: 'code',
                    title: '产品编码',
                },
                {
                    field: 'unit',
                    title: '单位'
                },
                {
                    field: 'price',
                    title: '单价'
                },
                {
                    field: 'num',
                    title: '数量'
                },
                {
                    field: 'status',
                    title: '状态',
                    visible:false,
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    field: 'supplierId',
                    title: '供应商ID',
                    visible: false
                },
                {
                    field: 'remark',
                    title: '备注'
                }
            ]
        };
        $.table.init(options);
    });
</script>
</body>
</html>
